cbuffer ConstantBuffer
{
	float4x4 matFinal;
    float4x4 rotation;

    float4 lightVector;
    float4 lightColor;
    float4 ambientLightColor;
	int textureNumber;
}

Texture2D Texture;
SamplerState ss;

struct VOut
{
	float4 color : COLOR;
	float2 textureCoord : TEXCOORD;
	float4 position : SV_POSITION;
};

VOut VShader(float4 position : POSITION, float4 normal : NORMAL, float2 texcoord: TEXCOORD)
{
	VOut output;

	output.position = mul(matFinal, position);

	output.color = ambientLightColor;

        float4 norm = normalize(mul(rotation, normal));
        float diffuseBrightness = saturate(dot(norm, lightVector));
        output.color += lightColor * diffuseBrightness;

	output.textureCoord = texcoord;

	return output;
}

float4 PShader(float4 color : COLOR, float2 texcoord : TEXCOORD) : SV_TARGET
{
    return color * Texture.Sample(ss, texcoord);
}